package com.oraro.paygatewaybiz.channel.wxpay.wxconfig;

import com.github.wxpay.sdk.IWXPayDomain;
import com.github.wxpay.sdk.WXPayConfig;
import com.github.wxpay.sdk.WXPayConstants;
import lombok.Setter;

import java.io.InputStream;

/**
 * @Author: jianghuiyong
 * @Date: 2018/11/28 16:49
 * @Version 1.0
 */
@Setter
public class WXPayConfigDefine extends WXPayConfig {

    private String appID;

    private String mchID;

    private String key;

    private InputStream certStream;

    public WXPayConfigDefine () {

    }
    public WXPayConfigDefine (String appID, String mchID, String key) {
        this.appID = appID;
        this.mchID = mchID;
        this.key = key;
    }

    @Override
    protected String getAppID() {
        return this.appID;
    }

    @Override
    protected String getMchID() {
        return this.mchID;
    }

    @Override
    protected String getKey() {
        return this.key;
    }

    @Override
    protected InputStream getCertStream() {
        return this.certStream;
    }

    @Override
    protected IWXPayDomain getWXPayDomain() {
        IWXPayDomain iwxPayDomain = new IWXPayDomain () {
            @Override
            public void report(String domain, long elapsedTimeMillis, Exception ex) {

            }

            @Override
            public DomainInfo getDomain(WXPayConfig config) {
                return new IWXPayDomain.DomainInfo(WXPayConstants.DOMAIN_API, true);
            }
        };
        return iwxPayDomain;
    }
}
